﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JXT.PrimaryKey.Batman.Container;
using JXT.PrimaryKey.Batman.Core.WcfService;
using JXT.PrimaryKey.Batman.Domain.Services;
using JXT.PrimaryKey.Batman.Domain.Repositories;
using JXT.PrimaryKey.Batman.Domain.Specifications;
using JXT.PrimaryKey.Batman.Core.Configuration;

namespace JXT.PrimaryKey.Batman.WcfService.Services
{
    public abstract class WcfServiceAttributeBase : ServiceAttributeBase
    {
        private ISpecificationFactory _specificationFactory;

        protected ISpecificationFactory SpecificationFactory
        {
            get
            {
                if (_specificationFactory == null)
                {
                    _specificationFactory = ContainerManager.Default.Resolve<ISpecificationFactory>();
                }
                return _specificationFactory;
            }
        }

        public ServiceConfigurationSection ServiceConfigration
        {
            get
            {
                return SupernovaConfigurationManager.GetServiceConfigurationSection();
            }
        }

        protected virtual TService LoadService<TService>() where TService : IService
        {
            return ServiceContainer.Resolve<TService>();
        }
    }
}
